package helper.base

object CloneHelper {
    interface Cloneable {
        fun clone(): Cloneable
    }

    object Expand {
        object StringList {
            fun ArrayList<String>.cloneList(
            ): ArrayList<String> {
                return ArrayList(this)
            }

            fun LinkedHashSet<String>.cloneList(
            ): LinkedHashSet<String> {
                val res = LinkedHashSet<String>()
                this.forEach {
                    res.add(it)
                }
                return res
            }
            fun HashSet<String>.cloneList(
            ): HashSet<String> {
                val res = LinkedHashSet<String>()
                this.forEach {
                    res.add(it)
                }
                return res
            }
        }

        object CloneableList {
            @Suppress("UNCHECKED_CAST")
            fun <E : Cloneable> List<E>.cloneList(
            ): List<E> {
                return this.map {
                    it.clone() as E
                }
            }
        }
    }
}